﻿using Glorysoft.SECSwell;
using System;

namespace Glorysoft.EAP.Core
{
    public static class DataUtils
    {
        public static string convertToStr(eSECS_FORMAT format, object value)
        {
            string result = "";
            if (value == null) { return ""; }
            switch (format)
            {
                case eSECS_FORMAT.BINARY:
                    byte[] val = value as byte[];
                    result = Convert.ToString(Convert.ToInt32(val[0]));
                    break;
                case eSECS_FORMAT.BOOLEAN:
                    result = value.ToString().ToUpper();
                    break;
                case eSECS_FORMAT.ASCII:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.JIS8:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.CHAR2:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.I1:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.I2:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.I4:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.I8:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.U1:
                    result = value?.ToString();
                    break;
                case eSECS_FORMAT.U2:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.U4:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.U8:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.F4:
                    result = value.ToString();
                    break;
                case eSECS_FORMAT.F8:
                    result = value.ToString();
                    break;
            }
            return result;
        }
    }
}
